﻿using Engine.Graphics;
using Engine.Graphics.VertexStructures;
using SharpDX;
using System.Collections.Generic;
using System.IO;

namespace street.GameDllInterfaces
{
    public interface IStreetAddin
    {
        #region Public Methods

        /// <summary>
        /// Created additional game vertices for road.
        /// </summary>
        /// <param name="middle">coordinates of middleline-spline.</param>
        /// <param name="vertices">engine vertices for roadmesh.</param>
        /// <param name="lengthOfStreet">complete length of the street</param>
        /// <param name="middleLineDistances">length for each middleline segment.</param>
        /// <param name="textureUcoordinates">same texturecoordinates which also used for road mesh</param>
        /// <param name="data">stored addindata for game specific vertices.</param>
        /// <returns></returns>
        List<IGameVertex> CreateGameVertices(Vector3[] middle, List<MyOwnVertex.PositionNormalTextured> vertices, float lengthOfStreet, float[] middleLineDistances, float[] textureUcoordinates, DataForGamevertexCalclation data);

        /// <summary>
        /// Create additional game vertices for crossroad.
        /// </summary>
        /// <param name="positions">position of street-joint</param>
        /// <param name="isMainstreet"></param>
        /// <returns></returns>
        List<IGameVertex> CreateGameVerticesForCrossroad(List<Vector3> positions, List<bool> isMainstreet);

        /// <summary>
        /// Creates additional game vertices for rail Part 1.
        /// </summary>
        /// <param name="middle"></param>
        /// <param name="verticesWr2Data"></param>
        /// <param name="textureUcoordinates"></param>
        void CreateGameVerticesGuardRailPart1(Vector3[] middle, List<IGameVertex> verticesWr2Data, float[] textureUcoordinates);

        /// <summary>
        /// Creates additional game vertices for rail Part 2.
        /// </summary>
        /// <param name="middle"></param>
        /// <param name="verticesWr2Data"></param>
        /// <param name="textureUcoordinates"></param>
        void CreateGameVerticesGuardRailPart2(Vector3[] middle, List<IGameVertex> verticesWr2Data, float[] textureUcoordinates);

        /// <summary>
        /// Creates additional game vertices for rail Part 3.
        /// </summary>
        /// <param name="middle"></param>
        /// <param name="verticesWr2Data"></param>
        void CreateGameVerticesGuardRailPart3(Vector3[] middle, List<IGameVertex> verticesWr2Data);

        /// <summary>
        /// Usercontrol for changeing the properties for vertexdata creation.
        /// </summary>
        /// <returns></returns>
        IStreetAddinControl GetControlForVertices();

        /// <summary>
        /// Return the gamename
        /// </summary>
        /// <returns></returns>
        string GetGameName();

        DataForGamevertexCalclation ReadStreetAddinData(BinaryReader br, int Version);

        void SaveStreetData(DataForGamevertexCalclation data, BinaryWriter bw);
        
        #endregion Public Methods
    }

    /// <summary>
    /// here are the gamespecific values stored, which are needed for vertex creation for game.
    /// </summary>
    public struct DataForGamevertexCalclation
    {
        #region Public Fields

        public object gameDllData;

        public int version;

        #endregion Public Fields

        #region Internal Fields

        internal int sizeInBytes;

        #endregion Internal Fields
    }
}